<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2017/9/28
  Time: 22:40
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>登录界面</title>
</head>
<script type="text/javascript" src="js/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="js/jquery.validate.min.js"></script>
<style>
    html, body {
        background-color: rgb(248, 246, 242);
        font-size: 14px;
        font-family: "微软雅黑";
    }

    form {
        margin-top: 40px;
    }

    #content {
        margin-top: 100px;
    }

    span {
        font-size: 30px;
        font-weight: 300;
    }

    input {
        width: 300px;
        height: 40px;
        border-radius: 3px;
        margin-top: 20px;
    }

    input[type=submit] {
        color: white;
        border: none;
        font-size: 20px;
        font-family: "微软雅黑";
        background-color: #5cb85c;
    }

    button {
        width: 300px;
        height: 40px;
        margin-top: 20px;
        border: none;
        color: gray;
        font-family: "微软雅黑";
        background-color: rgb(248, 246, 242);
        border-top: solid 1px gray;
    }

    a {
        text-decoration: none;
        font-size: 15px;
        color: black;
    }

    a:hover {
        color: red;
    }

    ul {
        list-style: none;
        margin-top: 15px;
        margin-left: 530px;
    }

    ul li {
        float: left;
        padding-left: 20px;
        font-size: 14px;

    }

</style>
<body>
<%

    if (session.getAttribute("errorMsg") != null){
        out.print(session.getAttribute("errorMsg"));
    }


    if (request.getParameter("exit") != null){
       session.removeAttribute("username");
       session.removeAttribute("isLogin");
       session.removeAttribute("password");
    }

%>
<div>
    <div id="content">
        <center>
            <span>作业管理系统</span>

            <ul>
                <li class="li" style="color: red" onclick="chaneUser(0,this)">学生登录</li>
                <li>|</li>
                <li class="li" onclick="chaneUser(1,this)">教师登录</li>
            </ul>

            <form id="login_from" action="${pageContext.request.contextPath}/login" method="post">
                <input type="text" name="username" value="<%=(session.getAttribute("username") != null?session.getAttribute("username"):"")%>" placeholder="请输入用户名">
                <br>
                <input type="password" name="password" value="<%=(session.getAttribute("password") != null?session.getAttribute("password"):"")%>" placeholder="请输入密码">
                <input type="hidden" id="userType" name="userType" value="0">
                <br>
                <input type="submit" value="登录">
            </form>

            <button><a href="register.jsp">点我注册</a><%--<a href="#" style="float: right ">忘记密码？</a>--%></button>


        </center>
    </div>

</div>
<script>
    $(function () {
        $("#login_from").validate({
            submitHandler: function (form) {
                form.submit();
            },
            rules: {
                username: "required",
                password: {
                    required: true,
                }
            },
            messages: {
                username: "请输入用户名",
                password: {
                    required: "请输入密码",
                }
            }
        });

    });

    function chaneUser(t, thisLi) {

        thisLi.style.color = "red";
        $(".li").not(thisLi).css('color', "black");
        $("#userType").val(t);

    }
</script>
</body>
</html>
